from selenium import webdriver
from selenium.webdriver.support.select import Select
from bs4 import BeautifulSoup
import time
import datetime

chrome_options = webdriver.ChromeOptions()
# chrome_options.add_argument('--headless')
# chrome_options.add_argument('--disable-gpu')
client = webdriver.Chrome(executable_path='D:\webdrivers\chromedriver.exe',
                          options=chrome_options)
#优米登录网址
url = "http://192.168.0.89:188/admin/login"
userid = "/html/body/div/form/div[2]/input"
passwdid = "/html/body/div/form/div[3]/input"
username = "jiyu@newspiral.net"
passwd = "Welcome1"
loginbutton = "/html/body/div/form/button"
zuzhijiagou = "/html/body/div[2]/nav/ul/li[2]/a"
#交付
jf = "/html/body/div[2]/div/div/div[1]/div/div/table/tbody/tr[4]/td[1]"
#南京交付ID:15
njjf = "/html/body/div[2]/div/div/div[1]/div/div/table/tbody/tr[20]/td[1]"
#广佛交付ID:7
gfjf = "/html/body/div[2]/div/div/div[1]/div/div/table/tbody/tr[19]/td[1]"
#搜索引擎框
sousuo = "/html/body/div[2]/div/div/div[1]/div/div/div/div[3]/form/input"

class youmi(object):
    def __init__(self, name, id, pos):
    #员工姓名
        self.name = name
    #员工加入的组织架构ID
        self.id = id
    #员工的角色
        self.pos = pos
    def Login():
        client.get(url)
    #账号登录-输入账号密码
        elemid = client.find_element_by_xpath(userid)
        elempasswd = client.find_element_by_xpath(passwdid)
        time.sleep(1)
        elemid.send_keys(username)
        elempasswd.send_keys(passwd)
    #点击登录
        elemlogin = client.find_element_by_xpath(loginbutton)
        elemlogin.click()
        # client.save_screenshot('1.png')
        # client.quit()

    def zuzhijiagou():
        #点击进入组织架构
        client.find_element_by_xpath(zuzhijiagou).click()

        #搜索你要输入的部门
        client.find_element_by_xpath(sousuo).send_keys("南京交付")
        client.find_element_by_xpath(' //*[@id="main-wrap"]/div/div/div[1]/div/div/div/div[3]/form/button').click()
        #点击交付中心
        # client.find_element_by_xpath(jf).click()
        # client.find_element_by_xpath(njjf).click()
        # client.save_screenshot('1.png')
        # client.quit()

# 获取页面所有内容
# content = client.page_source
# print(content)
# client.save_screenshot('1.png')
# client.quit()

